home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / usr / bin / sensible-browser < prev    next >
Encoding:
Text File  |  2007-03-05  |  1.0 KB  |  41 lines

  1. #!/usr/bin/perl
  2. # This program is copyright 2002 by Joey Hess <joeyh@debian.org>,
  3. # and is licensed under the terms of the GNU GPL, version 2 or higher.
  4. my $url=shift;
  5. if (exists $ENV{BROWSER}) {
  6.     foreach (split ':' , $ENV{BROWSER}) {
  7.         if (! /%s/) {
  8.             $_.=" %s";
  9.         }
  10.         # substitute %s with url, and %% to %.
  11.         s/%([%s])/$1 eq '%' ? '%' : $url/eg;
  12.         $ret=system split ' ', $_;
  13.         if ($ret >> 8 == 0) {
  14.             exit(0);
  15.         }
  16.         # on failure, continue to next in list
  17.     }
  18.  
  19.     print STDERR "None of the browsers in \$BROWSER worked!\n";
  20.     exit 1;
  21. }
  22.  
  23. if (exists $ENV{DISPLAY}) {
  24.     if (-e '/usr/bin/x-www-browser') {
  25.         exec '/usr/bin/x-www-browser', $url;
  26.         exit 1;
  27.     }
  28.     elsif (-e '/usr/bin/x-terminal-emulator' && -e '/usr/bin/www-browser') {
  29.         exec "x-terminal-emulator", "-e", "/usr/bin/www-browser", $url;
  30.         exit 1;
  31.     }
  32. }
  33. elsif (-e '/usr/bin/www-browser') {
  34.     exec '/usr/bin/www-browser', $url;
  35.     exit 1;
  36. }
  37.  
  38. print STDERR "Couldn't find a suitable web browser!\n";
  39. print STDERR "Set the BROWSER environment variable to your desired browser.\n";
  40. exit 1;
  41.